const ttPluginPages = [
  "ext://microapp-trade-plugin/order-confirm",
  "ext://microapp-trade-plugin/refund-apply",
  "ext://microapp-trade-plugin/refund-detail"
];

module.exports = (ctx) => {
  if (process.env.TARO_ENV === 'tt') {
    ctx.modifyBuildAssets(({ assets }) => {
      const appJsonStr = assets["app.json"].source();
      const appJsonParse = JSON.parse(appJsonStr);
      appJsonParse.pages = [...appJsonParse.pages, ...ttPluginPages];
      appJsonParse.fallbackPluginPages = {
        '/main/order/confirm': 'ext://microapp-trade-plugin/order-confirm'
      }
      assets["app.json"].source = () => JSON.stringify(appJsonParse);
    });
  }
};
